//def dec = 5
//
//def amin = new File('/home/auerf/Comparison/FULL Proteome/Id_PVal_QVal.txt')
//def pValues = [:]
//def qValues = [:]
//amin.eachLine{line->
//    def splitted = line.split('\t')
//    if(splitted[1]!='NA'){
//        pValues.put(splitted[0], splitted[1].toDouble().round(dec))
//        qValues.put(splitted[0], splitted[2].toDouble().round(dec))
//    }
//}
//
//
//def my = new File('/home/auerf/Comparison/FULL Proteome/p_q_Values.txt')
//my.eachLine{line->
//    def splitted = line.split('\t')
//    def pV = splitted[1].toDouble().round(dec)
//    def qV = splitted[2].toDouble().round(dec)
//    if((pV!=pValues[splitted[0]])||(qV!=qValues[splitted[0]])){
//        println ''+splitted[0]+'\t'+pV+'='+pValues[splitted[0]]+'\t'+qV+'='+qValues[splitted[0]]
//    }
//
//}

//def amin = new File('/home/auerf/Comparison/FULL Proteome/Id_PVal_QVal.txt')
//def pValues = [:]
//def qValues = [:]
//amin.eachLine{line->
//    def splitted = line.split('\t')
//    if(splitted[1]!='NA'){
//        def pValue = splitted[1].toDouble()
//        def qValue = splitted[2].toDouble()
//        pValues.put(splitted[0], pValue)
//        if(qValue<=0.05){qValues.put(splitted[0], qValue)}
//    }
//}
//
//println qValues.size()
//
//
//pValues = [:]
//qValues = [:]
//def my = new File('/home/auerf/Comparison/FULL Proteome/p_q_Values.txt')
//my.eachLine{line->
//    def splitted = line.split('\t')
//    def pValue = splitted[1].toDouble()
//    def qValue = splitted[2].toDouble()
//    pValues.put(splitted[0], pValue)
//    if(qValue<=0.05){qValues.put(splitted[0], qValue)}
//}
//println qValues.size()


//def dec = 10

def amin = new File('/home/auerf/Comparison/FULL Proteome/Id_PVal_QVal.txt')
def pValues = [:]
def qValues = [:]
amin.eachLine{line->
    def splitted = line.split('\t')
    if(splitted[1]!='NA'){
        pValues.put(splitted[0], splitted[1].toDouble())
        qValues.put(splitted[0], splitted[2].toDouble())

//        pValues.put(splitted[0], splitted[1].toDouble().round(dec))
//        qValues.put(splitted[0], splitted[2].toDouble().round(dec))

//        pValues.put(splitted[0], splitted[1].toDouble().trunc(dec))
//        qValues.put(splitted[0], splitted[2].toDouble().trunc(dec))
    }
}


def my = new File('/home/auerf/Comparison/FULL Proteome/p_q_Values.txt')
def mypValues = [:]
def myqValues = [:]
my.eachLine{line->
    def splitted = line.split('\t')
    mypValues.put(splitted[0], splitted[1].toDouble())
    myqValues.put(splitted[0], splitted[2].toDouble())

//    mypValues.put(splitted[0], splitted[1].toDouble().round(dec))
//    myqValues.put(splitted[0], splitted[2].toDouble().round(dec))
//
//    mypValues.put(splitted[0], splitted[1].toDouble().trunc(dec))
//    myqValues.put(splitted[0], splitted[2].toDouble().trunc(dec))
}

//myqValues.each{println it.key}

def myIdList = myqValues.sort{i1,i2->(i1.value.compareTo(i2.value)==0)?i1.key.compareTo(i2.key):i1.value.compareTo(i2.value)}.keySet() as List
def aminIdList = qValues.sort{i1,i2->(i1.value.compareTo(i2.value)==0)?i1.key.compareTo(i2.key):i1.value.compareTo(i2.value)}.keySet() as List
aminIdList.eachWithIndex{id,index->
    println 'my: '+myIdList[index]+' Amin: '+id+'\t'+myqValues[myIdList[index]]+' '+qValues[id]+((myIdList[index]!=id)?'\tnot equal!':'')
//    if(myIdList[index]==id){
//
//    }else{
//        println 'unequal: '+id
//    }
}